<%@ page language="java" errorPage="/error.jsp" pageEncoding="UTF-8" contentType="text/html; charset=utf-8" %>
<%@include file="/quick/include/common.jsp"%>
<c:set var="buttons">
    <input type="button" style="margin-right: 5px"   onclick="f_read()" iconType="read"  value="<fmt:message key="button.view"/>"/>
    <input type="button" style="margin-right: 5px"   onclick="f_query()" value="<fmt:message key="button.query"/>"/>
</c:set>
<div id='toolbar' style="display:none">
<c:out value="${buttons}" escapeXml="false"/>
</div>
 
<div id='parameter_form'></div>
<script>
Ext.onReady(globalScope._ready);
Ext.onReady(function(){
  globalScope.grid.get("<c:out value='${model.tableName}'/>").on('rowdblclick',f_read);
  Ext.get('title').dom.style.display='none';
  
	var yearStore=new Ext.data.SimpleStore({
     'fields':['value','text'],
     data:<c:out value="${yearJson}" escapeXml='false' />
	});
	var semesterStore=new Ext.data.SimpleStore({
     'fields':['value','text'],
     data:<c:out value="${semesterJson}" escapeXml='false' />
	});

	form = new Ext.form.FormPanel({
	     el:'parameter_form',
  		labelAlign:'right',
	    frame:true,
	    border:true,
	    height:40,
	    items:[{
	          layout:'column',
	          items:[{
	            layout:'form',
	            columnWidth:1/4,
	            items:[{
			            xtype:'combo',   
			            fieldLabel:'学年度',  
			            store: yearStore,   
			            editable: false,   
			            mode: 'local',   
			            hiddenName:'SCHOOL_YEAR',   
			            id:'_YEAR',   
			            displayField:'text',   
			            valueField:'value',
			            triggerAction: 'all', 
			            emptyText:'请选择',
			            value:'<c:out value="${model.parameter.SCHOOL_YEAR}"/>',   
			            width:200         
			         }
	         ]},{
	           layout:'form',
	           columnWidth:1/4,
	           items:[
			         {
			            xtype:'combo',   
			            fieldLabel:'学期',   
			            store: semesterStore,   
			            mode: 'local',   
			            hiddenName:'SCHOOL_SEMESTER',   
			            id:'_SEMESTER',   
			            displayField:'text',   
			            valueField:'value',   
			            triggerAction: 'all',   
			            emptyText:'请选择',   
			            value:'<c:out value="${model.parameter.SCHOOL_SEMESTER}"/>',   
			            width:200         
			         }
            ]},{
	           layout:'form',
	           columnWidth:1/4,
	           items:[
	             {
			           xtype:'button',
			           text:'确定',
			           handler:function(){
			                var postData=form.getForm().getValues();
			                globalScope._changeQuickCookie('SCHOOL_YEAR',postData.SCHOOL_YEAR);
			                globalScope._changeQuickCookie('SCHOOL_SEMESTER',postData.SCHOOL_SEMESTER);
			                postData={};
			                var ycTable='<c:out value="${model.parameter.tableName}"/>';
						    globalScope._model(postData,function(responseText){
						        var htmlDiv=Ext.get("table_html").dom;
							    htmlDiv.innerHTML=responseText;
							    var htmlTable=Ext.get(ycTable);
							    globalScope.grid.get(ycTable).reloadData(htmlTable);
							    globalScope.queryWin.get(ycTable).afterQuery(responseText);	
						   },true);			           
			           }
			         }
	           ]
            }
          ]  
         }
       ]
	});
   form.render();  
});  


<c:if test='${not empty model.parentId}'>
function f_back(){
   history.back();
}
</c:if>
function f_excel(){
  globalScope._exportExcel();
//  globalScope._excel();
}


function f_read(){
 globalScope._view();
}
function f_query(tableName){
    globalScope._query(tableName);
}
function f_gotoPage(pageNo,rowsOfPage,pageCount,rowCount,conditoin){
  globalScope._gotoPage({dealCookie:true,spanName:"g_pageSpan_<c:out value='${model.tableName}'/>",pageNo:pageNo,rowsOfPage:rowsOfPage,pageCount:pageCount,rowCount:rowCount,condition:conditoin,tableName:"<c:out value='${model.tableName}'/>"});
}
</script>
